package com.mpq.config;

import com.mpq.utils.DateUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author mingpingqiang on 2018/11/30/13:46
 * Created by mingpingqiang on 2018/11/30/13:46
 */
@Component
@EnableScheduling
public class JobsConfig {
    public final static long ONE_Minute =  60 * 10000;

    @Scheduled(fixedDelay=ONE_Minute)
    public void fixedDelayJob(){
        System.out.println(DateUtils.dateToString(new Date(),DateUtils.DATE_TIME_FORMAT)+" >>fixedDelay执行....");
    }

    @Scheduled(fixedRate=ONE_Minute)
    public void fixedRateJob(){
        System.out.println(DateUtils.dateToString(new Date(),DateUtils.DATE_TIME_FORMAT)+" >>fixedRate执行....");
    }

    @Scheduled(cron="0 15 3 * * ?")
    public void cronJob(){
        System.out.println(DateUtils.dateToString(new Date(),DateUtils.DATE_TIME_FORMAT)+" >>cron执行....");
    }
}
